<%@page import="org.ipo.mm.web.util.ConstantManager, java.util.Collection, org.ipo.mm.web.util.security.SecurityManager" %>
<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@taglib prefix="l" uri="http://struts.apache.org/tags-logic" %>
<%@taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>




<h1><b:message key="menu_cities"/></h1>
<%
            Collection<Integer> privileges = (Collection<Integer>) request.getSession().getAttribute(ConstantManager.SESSION_USER_PRIVILEGES);
            if (privileges.contains(SecurityManager.CREATE_CITY_PRIVILEGE)) {%>

<h:link styleClass="createNew" action="/protected/dispatch?method=showCreateCityForm"><b:message key="cities_create"/></h:link><br>

<%}%>


<div class="tabela">
    <table width="100%" border="0" >
        <tr>
            <th scope="col"><b:message key="cities_name"/></th>
            <th scope="col"><b:message key="cities_zip"/></th>
            <!--<th scope="col"><b:message key="gen_note"/></th>-->
            <th scope="col" nowrap="true"><b:message key="gen_action"/></th>
        </tr>
        
        <l:iterate id="city" name="showCities.cities" scope="request">
            <tr class="red1"><!--treba da ide red2 u svakom drugom-->
                <td>
                    <%--
                    <!-- SECURITY CONSTRAINT USER CAN EDIT ONLY ENTITIES HE CREATED -->
                    <c:choose>
                        <c:when test="${(USER == city.user) || (USER.type == USER_TYPE_ADMIN_PA)}">
                            <h:link action="/protected/dispatch?method=showUpdateCityForm"
                                    paramId="cid" paramName="city" paramProperty="id">
                                <b:write name="city" property="name"/>
                            </h:link>


                        </c:when>
                        <c:otherwise>
                            <b:write name="city" property="name"/>  
                        </c:otherwise>
                    </c:choose>
                    --%>
                    <h:link action="/protected/institution_search" paramId="cid" paramName="city" paramProperty="id">
                        <span style="font-weight: bolder">
                            <b:write name="city" property="name"/>
                        </span>
                    </h:link>

                </td>
                <td><b:write name="city" property="zipCode"/></td>
                <!--<td><b:write name="city" property="note"/></td>-->
                <td nowrap="true">

                    <%

            if (privileges.contains(SecurityManager.DELETE_CITY_PRIVILEGE)) {%>

                    <h:link styleClass="delete" action="/protected/dispatch?method=deleteCity"
                            paramId="cid" paramName="city" paramProperty="id" onclick="return confirm('Are you sure you want to delete this item?/Da li ste sigurni da zelite da izbrisete ovaj entitet?')"
                            ><b:message key="gen_delete"/></h:link>

                    <%}%>
                    <%--
                    <c:if test="${(USER == city.user) || (USER.type == USER_TYPE_ADMIN_PA)}">
                        <h:link  styleClass="details"  action="/protected/dispatch?method=showUpdateCityForm"
                                paramId="cid" paramName="city" paramProperty="id">
                            <b:message key="gen_update"/>
                        </h:link>
                    </c:if>
                    --%>
                    <%
            if (privileges.contains(SecurityManager.EDIT_CITY_PRIVILEGE)) {

                    %>

                    <h:link  styleClass="details"  action="/protected/dispatch?method=showUpdateCityForm"
                             paramId="cid" paramName="city" paramProperty="id">
                        <b:message key="gen_update"/>
                    </h:link>
                    <%}%>

                </td>
            </tr>
        </l:iterate>
        <tr>
            <th scope="col"><b:message key="cities_name"/></th>
            <th scope="col"><b:message key="cities_zip"/></th>
            <!--<th scope="col"><b:message key="gen_note"/></th>-->
            <th scope="col" nowrap="true"><b:message key="gen_action"/></th>
        </tr>
    </table>
</div><!--tabela-->


